package com.yf.openapi.modules.stat.controller;

import com.yf.base.api.api.ApiRest;
import com.yf.base.api.api.controller.BaseController;
import com.yf.base.api.api.dto.BaseUserReqDTO;
import com.yf.openapi.modules.stat.dto.response.UserListRespDTO;
import com.yf.openapi.modules.stat.mapper.OpenUserListStatMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = {"用户待办统计"}, consumes = "用户数量统计、小气泡等场景")
@RestController
@RequestMapping("/api/open/user/list")
public class OpenUserListStatController extends BaseController {

    @Autowired
    private OpenUserListStatMapper openUserListStatMapper;

    @ApiOperation(value = "用户待学习课程统计", notes = "统计用户可学习的课程数量")
    @PostMapping(value = "/course")
    public ApiRest<UserListRespDTO> listCourse(@RequestBody BaseUserReqDTO reqDTO) {
        int count = openUserListStatMapper.courseListStat(reqDTO.getUserId());
        return success(new UserListRespDTO(count));
    }

    @ApiOperation(value = "用户待考试数量统计", notes = "统计用户可考试的考试数量")
    @PostMapping(value = "/exam")
    public ApiRest<UserListRespDTO> listExam(@RequestBody BaseUserReqDTO reqDTO) {
        int count = openUserListStatMapper.examListStat(reqDTO.getUserId());
        return success(new UserListRespDTO(count));
    }
}
